<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title>聊天列表</title>
		<link rel="stylesheet" type="text/css" href="../css/hui.css" />
		<link rel="stylesheet" type="text/css" href="../css/common.css" />
		<link rel="stylesheet" type="text/css" href="../css/homepage.css" />
		<script src="../js/common/flexible_css.debug.js" type="text/javascript" charset="utf-8"></script>
		<!--<script src="../js/common/flexible.debug.js" type="text/javascript" charset="utf-8"></script>-->
	</head>

	<body>
		<header class="hui-header">
			<div id="hui-back"></div>
		    <h1>聊天列表</h1>
		</header>
		<div class="hui-wrap hui-wrap-bottom">
		    <div class="hui-media-list" style="padding:10px;">
		        <ul class="hui-media-listUl">
	            	<!--<li>
		                <a href="javascript:void(0)">
		                    <div class="hui-media-list-img">
		                    	<img src="../img/3.jpg" />
		                    </div>
		                    <div class="hui-media-content">
		                        <h1>张三</h1>
		                        <p>2018-1-1</p>
		                    </div>
		                </a>
	            	</li>-->
		        </ul>
		    </div>
		</div>
		<script src="../js/hui/hui.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/common/common.js" type="text/javascript" charset="utf-8"></script>
		<script>
			//获取token
			var token = localStorage.getItem("token");	
			console.log('token：'+token)
			hui.ajax({
			    type : 'Post',
			    url : globleobj['domain2']+'/message/getchatlist',
			    data : {'userToken':'46q7xrrvzafk28h41vsfspl9z9es4fl8'},
			    beforeSend : function(){hui.loading();},
			    complete   : function(){hui.closeLoading();},
			    success : function(msg){
			    	console.log('getgroups:'+msg)
			    	var data = JSON.parse(msg)
			    	if(data.rc != 0){
			    		hui.toast(data.msg);
			    		return false; 
			    	}
			    	var options = ''; 
			    	for(var i= 0;i< data.msglist.length; i++){
			    		options += '<li  onclick="teamDetails('+JSON.stringify(data.msglist[i]).replace(/"/g, "&quot;")+')">'
										+'<a href="javascript:void(0)">'
											+'<div class="hui-media-list-img">'
												+'<img src="'+data.msglist[i].headimg+'" />'
											+'</div>'
											+'<div class="hui-media-content">'
												+'<h1>'+data.msglist[i].name+'</h1>'
												+'<p>'+data.msglist[i].lastMsg.time+'</p>'
											+'</div>'
										+'</a>'
									+'</li>'
			    	}
			    	hui('.hui-media-listUl').html(options);
			    	
			    },
			    error : function(e){
			        console.log(JSON.stringify(e));
			        hui.iconToast('读取消息失败', 'warn');
			    } 
			}); 		
			
			
			function teamDetails(getchatInfo){
			//	console.log(JSON.stringify(captain))
				var captain = JSON.stringify(getchatInfo);
				localStorage.setItem("getchatInfo",getchatInfo);
				hui.open('/html/imChat.html',{},true);
			}
			hui.ready(function(){
			    hui.plusReady(function(){
			    	console.log('plusReady')
			    });
			});
		</script>
	</body>
</html>